from tools.driver import open_dingstock
from unittest import TestCase
from pages.recommend_page import RecommendPage
from pages.mine_page import MinePage
from pages.newest_page import NewestPage
import unittest
from time import sleep


class TestComment(TestCase):
    def setUp(self) -> None:
        self.driver = open_dingstock()
        self.recommendpage = RecommendPage(self.driver)
        self.minepage = MinePage(self.driver)
        self.newestpage = NewestPage(self.driver)

    def tearDown(self) -> None:
        sleep(1)
    
    def test_a_customer_center(self):
        """个人中心跳转客服中心-展开收起第一个秒杀神器问题"""
        self.recommendpage.switch_mine()
        self.minepage.into_customer_center()
        text = self.minepage.customer_title()
        self.minepage.click_position(0.932, 0.252)
        # 展开秒杀神器第一个问题
        sleep(1)
        self.minepage.click_position(0.496, 0.134)
        # 点击监控/推送问题
        sleep(1)
        self.minepage.click_position(0.815, 0.133)
        # 点击会员/续费问题
        sleep(1)
        self.minepage.click_position(0.193, 0.185)
        # 点击社区问题
        sleep(1)
        self.minepage.click_position(0.506, 0.186)
        # 点击其他问题
        sleep(1)
        self.minepage.click_position(0.799, 0.187)
        # 点击客服中心
        sleep(1)
        self.minepage.click_position(0.941, 0.254)
        # 收起第一个问题
        sleep(1)
        self.minepage.swipe('down',1)
        error = self.minepage.is_text_toast_exist('服务异常')
        assert text == "帮助与反馈" and error == False
        
    # @unittest.skip("测试个人中心下拉刷新是否显示服务异常")
    def test_b_customer_center(self):
        self.recommendpage.switch_mine()
        self.minepage.swipe('down',1)
        assert self.minepage.is_text_toast_exist('服务异常') == False
        

if __name__ == '__main__':
    unittest.main()